from infirmary_admin_src.infirmary_common.infirmary_controller import IBaseController
from infirmary_admin_src.infirmary_common.infirmary_controller.rest_controller_with_depends import \
    RestControllerWithDepends
from fastapi import Request, Depends, Path, Body

from infirmary_admin_src.infirmary_smart_admin.infirmary_biz.infirmary.businesses.schemas import SchemaBase
from infirmary_admin_src.infirmary_smart_admin.infirmary_biz.infirmary.businesses.services.service_businesses import \
    Businesses



class XParam(SchemaBase):
    '''
    账号密码登录参数
    '''
    appid: str = Body(..., title="appid", )
    location_name: str = Body(..., title="location_name", )
    location: str = Body('', title="location", )
    si_number: str = Body(..., title="si_number", )
    si_name: str = Body('', title="si_name", )
    addr: str = Body('', title="addr", )
    tel: str = Body(default=None, title="tel", )
    remakl: str = Body('', title="remakl", )
    status: int = Body(0, title="status", )
    is_opened: int = Body(1, title="is_opened", )
    sort: int = Body(0, title="sort", )



class IController(IBaseController):
    '''
    定制相关约束检测函数逻辑步序
    '''

    def __init__(self, *, request: Request,
                 schema_param: XParam,
                 ):
        super().__init__(request=request)
        # 入参参数
        # 入参参数
        self.schema_param = schema_param


@RestControllerWithDepends()
class InfirmaryBusinessesStationAddController(IController):

    def business_login(self):
        pass
        result = Businesses.add_station_info(**self.schema_param.dict())
        if result:
            self.response_msg = '添加成功'
        else:
            self.response_ok = False
            self.response_msg = '添加失败'
            return None

        return None
